/**
 * @name BreadCrumb
 * @author
 * @desc 面包屑导航
 */

import React, { Component } from 'react'
import { Breadcrumb } from 'antd'

import styles from './styles.module.less'

class BreadCrumbs extends Component {
  crumbs = (item, index, proroute) => {
    if (index + 1 === proroute.length) {
      return <Breadcrumb.Item key={item.title}>{item.title}</Breadcrumb.Item>
    } else {
      return (
        <Breadcrumb.Item key={item.path} href={item.path}>
          {item.title}
        </Breadcrumb.Item>
      )
    }
  }
  render() {
    const { proroute } = this.props
    return (
      <div>
        <Breadcrumb>{proroute ? proroute.map((item, index) => this.crumbs(item, index, proroute)) : null}</Breadcrumb>
      </div>
    )
  }
}
export default BreadCrumbs
